package com.ydche.client;

import com.ydche.idl_output.IDao;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

public class SimpleClient {
    private static TTransport transport;
    private static IDao.Client client;

    public static IDao.Client getClient() {
        if(client == null) {
            try {
                transport = new TSocket("localhost", 5200);
                transport.open();
                TProtocol protocol = new TBinaryProtocol(transport);
                client = new IDao.Client(protocol);
            } catch (TException x) {
                x.printStackTrace();
            }
        }
        return client;
    }
}
